package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/5/30 16:49
 * @since v1.0
 */
@Getter
public enum CompanyConfigDescribeEnum {
    //
    CONTRACT_PERFORMANCE_RULE_SET("contractPerformanceRule", "enum.companyConfigDescribe.title.contract_performance_rule_set", "enum.companyConfigDescribe.tips.contract_performance_rule_set"),
    SHARE_FOCUS_CUSTOMER_CHECK_SET("shareFocusCustomer", "enum.companyConfigDescribe.title.share_focus_customer_check_set", "enum.companyConfigDescribe.tips.share_focus_customer_check_set"),
    SHARE_FOCUS_OPPORTUNITY_CHECK_SET("shareFocusOpportunity", "enum.companyConfigDescribe.title.share_focus_opportunity_check_set", "enum.companyConfigDescribe.tips.share_focus_opportunity_check_set"),
    ZERO_STOCK("zeroStock", "enum.companyConfigDescribe.title.zero_stock", ""),
    UNKNOW("", "", ""),;


    private String configAlias;

    private String title;

    private String tips;

    CompanyConfigDescribeEnum(String configAlias, String title, String tips) {
        this.configAlias = configAlias;
        this.title = title;
        this.tips = tips;
    }

    public static CompanyConfigDescribeEnum getCompanyConfigDescribeEnumByAlias(String configAlias) {
        for (CompanyConfigDescribeEnum cache : values()) {
            if (Objects.equals(configAlias, cache.getConfigAlias())) {
                return cache;
            }
        }
        return UNKNOW;
    }

    public String getTitle() {
        return I18nMessageUtil.getMessage(title);
    }

    public String getTips() {
        return I18nMessageUtil.getMessage(tips);
    }
}
